/*
 * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved
 * Use is subject to license terms.
 *
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#if !defined(UNIT_TEST_H)

#define UNIT_TEST_H
#include <dirent.h>

typedef int apr_time_t;

#define APR_UUID_FORMATTED_LENGTH 200

typedef struct { char u[100]; } apr_uuid_t;

typedef struct {
  int foo;
} apr_bucket_brigade;
typedef long apr_off_t;
typedef struct {
  int count;
  char * keys[100];
  char * values[100];
} apr_hash_t;
typedef struct {
  int foo;
} apr_xml_parser;
typedef struct {
  char * port_str;
} apr_uri_t;

typedef struct {
  int foo;
} apr_pool_t;

typedef struct {
  int filetype;
  char *name;
  int size;
  apr_time_t mtime;
  int inode;
} apr_finfo_t;

typedef struct {
  int foo;
  char * server_hostname;
  int port;
} server_rec;

typedef struct {
  int bucket_alloc;
} connection_t;

typedef struct {
  int foo;
} apr_bucket;

typedef struct {
  int status;
  char * hostname;
  apr_uri_t parsed_uri;
  apr_pool_t * pool;
  char * uri;
  char * filename;
  char * canonical_filename;
  void * headers_out;
  int header_only;
  int method_number;
  char * content_type;
  apr_finfo_t finfo;
  void * headers_in;
  server_rec * server;
  apr_time_t request_time;
  apr_time_t mtime;
  connection_t * connection;
  int input_filters;
  char * args;
} request_rec;

typedef struct {
  int nelts;
  char * elts;
  int size;
} apr_array_header_t;

typedef struct {
  server_rec * server;
  apr_pool_t * pool;
} cmd_parms;

typedef struct {
  int tm_year;
  int tm_mon;
  int tm_mday;
} apr_time_exp_t;

typedef int apr_fileperms_t;

typedef struct {
  int foo;
} apr_file_t;


typedef struct {
  int foo;
} ap_regex_t;

typedef struct {
  int foo;
} ap_regmatch_t;

typedef struct {
  int foo;
} apr_global_mutex_t;

typedef struct {
  DIR * dir;
} apr_dir_t;

typedef struct {
  void * text;
  void * next;
} apr_text;

typedef struct {
  apr_text * first;
  apr_text * last;
} apr_text_header;

typedef struct apr_xml_attr apr_xml_attr;
struct apr_xml_attr {
  apr_xml_attr * next;
  int ns;
  char * name;
  char * value;
};

typedef struct apr_xml_elem apr_xml_elem;
struct apr_xml_elem {
  int ns;
  char * lang;
  apr_xml_attr * attr;
  char * name;
  void * next;
  void * parent;
  apr_xml_elem * first_child;
  apr_text_header first_cdata;
  apr_text_header following_cdata;
};

typedef struct {
  apr_array_header_t * namespaces;
  apr_xml_elem * root;
} apr_xml_doc;

typedef int apr_status_t;

typedef int apr_size_t;


apr_bucket_brigade * apr_brigade_create(apr_pool_t * pool, int ba);
apr_array_header_t * apr_array_make(apr_pool_t *, int, int);
void * apr_array_push(apr_array_header_t *);
char * apr_pstrdup(apr_pool_t *, const char *);
char * apr_psprintf(apr_pool_t *, char *, ...);
char * apr_pstrcat(apr_pool_t *, char *, ...);
void ap_log_error(int mark, int a, int b, server_rec * s, char * fmt, ...);
ap_regex_t * ap_pregcomp(apr_pool_t *, char *, int);
char * ap_pregsub(apr_pool_t * p, char * dollars, char * orig, int nm, ap_regmatch_t * regm);
int ap_pregexec(ap_regex_t * re, char * str, apr_size_t nmatch,
		ap_regmatch_t * matches, int flags);
void ap_rputs(char * s, request_rec * r);
void ap_set_content_type(request_rec * r, char * s);
void * apr_palloc(apr_pool_t * p, int size);
void * apr_pcalloc(apr_pool_t * p, int size);
int apr_stat(apr_finfo_t * finfo, char * f, int m, apr_pool_t * p);
void apr_table_set(void * t, char * k, char * v);
apr_status_t ap_xml_parse_input(request_rec * r, apr_xml_doc * * doc);
apr_status_t apr_dir_make_recursive(char * name, apr_fileperms_t p,
				  apr_pool_t * pool);
void apr_file_close(apr_file_t * f);
apr_status_t apr_file_open(apr_file_t * * f, char * sf, int x,
			   apr_fileperms_t perms, apr_pool_t * pool);
int apr_file_remove(char * fn, apr_pool_t * p);
int apr_isxdigit(int x);
void * apr_table_get(void * t, char * v);
void apr_time_exp_lt(apr_time_exp_t * tt, apr_time_t ttt);
apr_time_t apr_time_now();
apr_status_t apr_file_write_full(apr_file_t * f, void * s,int l, int * w);
apr_status_t apr_dir_open(apr_dir_t * * dir, char * path, apr_pool_t * pool);
apr_status_t apr_dir_read(apr_finfo_t * finfo, int x, apr_dir_t * dir);
void apr_dir_close(apr_dir_t * dir);
apr_status_t apr_global_mutex_create(apr_global_mutex_t * * m,
				     char * lockname, int x, apr_pool_t * pool);
apr_status_t apr_global_mutex_lock(apr_global_mutex_t * m);
apr_status_t apr_global_mutex_destroy(apr_global_mutex_t * m);
apr_status_t apr_global_mutex_unlock(apr_global_mutex_t * m);
void apr_strftime(char * buf, apr_size_t * time_len, int size, char * fmt,
		  apr_time_exp_t * times);
char * apr_strerror(apr_status_t status, char * buf, int size);
char * ap_make_etag(request_rec * r, int t);
apr_hash_t * apr_hash_make(apr_pool_t * p);
void * apr_hash_get(apr_hash_t * h, void * k, int l);
void apr_hash_set(apr_hash_t * h, void * k, int l, void * v);
apr_bucket * APR_BRIGADE_FIRST(apr_bucket_brigade * b);
apr_bucket * APR_BRIGADE_SENTINEL(apr_bucket_brigade * b);
apr_bucket * APR_BUCKET_NEXT(apr_bucket * b);
int APR_BUCKET_IS_EOS(apr_bucket * b);
int APR_BUCKET_IS_METADATA(apr_bucket * b);
apr_status_t ap_get_brigade(int i, apr_bucket_brigade * b, int m, int rw,
			      int bufsize);
int ap_get_limit_req_body(request_rec * r);
int apr_brigade_cleanup(apr_bucket_brigade * b);
apr_bucket_brigade * apr_brigade_create(apr_pool_t * p, int alloc);
int apr_brigade_destroy(apr_bucket_brigade * b);
apr_status_t apr_bucket_read(apr_bucket * b, const char * * d, int * l, int m);
int ap_rflush(request_rec * r);
int ap_rwrite(char * s, int l, request_rec * r);

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <time.h>

#define OK 1
#define DECLINED 2
#define DOCTYPE_HTML_4_0S "<!DOCTYPE html>"
#define APR_FINFO_TYPE 0x1
#define APR_FINFO_OWNER 0x2
#define APR_FINFO_PROT 0x4
#define APR_FINFO_SIZE 0x8
#define APR_FINFO_INODE 0x10

#define APR_HOOK_MIDDLE 1
#define APR_SUCCESS 1
#define APR_FINFO_MIN 1
#define APR_FINFO_NAME 1
#define APR_FINFO_MTIME 1

#define APR_HASH_KEY_STRING -1

#define AP_REG_EXTENDED 1

#define AP_MODE_READBYTES 1
#define APR_BLOCK_READ 1

#define APLOG_MARK 1
#define APLOG_ERR 1
#define APLOG_INFO 1

#define M_GET 1
#define M_POST 2
#define M_PUT 3
#define M_DELETE 4

#define HTTP_METHOD_NOT_ALLOWED 401
#define HTTP_UNSUPPORTED_MEDIA_TYPE 402
#define HTTP_FORBIDDEN 403
#define HTTP_NOT_FOUND 404
#define HTTP_PRECONDITION_FAILED 412
#define HTTP_INTERNAL_SERVER_ERROR 500
#define HTTP_NO_CONTENT 204

#define APR_FPROT_UREAD 1
#define APR_FPROT_UWRITE 1
#define APR_FPROT_UEXECUTE 1
#define APR_FPROT_GREAD 1
#define APR_FPROT_GWRITE 1
#define APR_FPROT_GEXECUTE 1

#define APR_FOPEN_WRITE 1
#define APR_FOPEN_CREATE 1
#define APR_FOPEN_DELONCLOSE 1
#define APR_FOPEN_READ 1
#define APR_FOPEN_EXCL 1

#define APR_DIR 1
#define APR_REG 2

#define APR_LOCK_DEFAULT 1

#define APR_XML_NS_NONE -10

#define LOCK_FILE "lock."

int suppress_writing_collection();

#endif
